package edu.pku.sei.transformation.editor.parser.expression.element;

import java.util.ArrayList;

import edu.pku.sei.modeler.model.core.MetaModelElement;

public class CompoundExpression extends Expression {
	private ArrayList<Expression> exps = new ArrayList<Expression>();

	public ArrayList<Expression> getExps() {
		return exps;
	}

	public void setExps(ArrayList<Expression> exps) {
		this.exps = exps;
	}

	@Override
	public boolean bind(Object context) {
		boolean result = true;
		for (Expression exp : exps) {
			result = result && exp.bind(context);
		}
		return result;

	}

	// public Element toXML(Element root) {
	// Element ele = root.addElement("compound");
	// for (int i = 0; i < exps.size(); i++) {
	// exps.get(i).toXML(ele);
	// }
	// return ele;
	// }

	@Override
	public MetaModelElement getType() {
		if (exps.size() != 0)
			return exps.get(exps.size() - 1).getType();
		else
			return null;
	}

	@Override
	public void sendHighLightNotify() {
		for (Expression exp : exps) {
			exp.sendHighLightNotify();
		}
	}

	@Override
	public void cancelHighLightNotify() {
		for (Expression exp : exps) {
			exp.cancelHighLightNotify();
		}
	}

	@Override
	public void removeInvalidBinding() {
		for (Expression exp : exps) {
			exp.removeInvalidBinding();
		}
	}

}
